#!/bin/sh

echo "=============开始导入数据库============="
echo "创建quick_core_dev数据库."
docker exec -i quick-mysql  sh -c "exec mysql -uroot -p123456 -e \"create database quick_core_dev;\""

echo "创建quick_log_v2数据库."
docker exec -i quick-mysql  sh -c "exec mysql -uroot -p123456 -e \"create database quick_log_v2;\""

echo "查看数据库."
docker exec -i quick-mysql  sh -c "exec mysql -uroot -p123456 -e \"show databases;\""

echo "创建用户quick_core_dev."
docker exec -i quick-mysql  sh -c "exec mysql -uroot -p123456 -e \"CREATE USER 'quick_core_dev'@'%' IDENTIFIED BY 'quick_core_dev';\""

echo "给quick_core_dev用户授权."
docker exec -i quick-mysql  sh -c "exec mysql -uroot -p123456 -e \"GRANT ALL PRIVILEGES ON quick_core_dev.* TO 'quick_core_dev'@'%';\""

echo "创建用户quick_log_v2."
docker exec -i quick-mysql  sh -c "exec mysql -uroot -p123456 -e \"CREATE USER 'quick_log_v2'@'%' IDENTIFIED BY 'quick_log_v2';\""

echo "给quick_log_v2用户授权."
docker exec -i quick-mysql  sh -c "exec mysql -uroot -p123456 -e \"GRANT ALL PRIVILEGES ON quick_log_v2.* TO 'quick_log_v2'@'%';\""

# 刷新权限
echo "刷新权限."
docker exec -i quick-mysql  sh -c "exec mysql -uroot -p123456 -e \"flush privileges;\""

echo "quick_core_dev数据库导入."
docker exec -i quick-mysql  sh -c 'exec mysql -uroot -p123456 quick_core_dev'< /ainiteam/quick/server/quick_core_dev.sql

echo "quick_log_v2数据库导入."
docker exec -i quick-mysql  sh -c "exec mysql -uroot -p123456 quick_log_v2"< /ainiteam/quick/server/quick_log_v2.sql